// import createDict from "../../ingrun/dict/index";
import createDict from "../../../dist/irdict@3.1.0/index";

import request from "../request";
import vue from "vue";

const instance = createDict(vue, {
  labelKey: "dictLabel",
  valueKey: "dictValue",
  remoteMethod: (dictKey, addDictItme) => {
    request.get("/system/dict/data/type/" + dictKey).then((res) => {
      addDictItme(dictKey, res.data, true);
    });
  },
});



vue.prototype.$getDictLabel = instance.getDictLabel;
vue.prototype.$getDictList = instance.getDictList;
vue.prototype.$getDictLabelAsync = instance.getDictLabelAsync;
vue.prototype.$getDictListAsync = instance.getDictListAsync;


export default instance;


async function preloadDictList(list) {
  await request.get("/system/dict/data/types/" + list).then((res) => {
    for (const key in res.data) {
      instance.addDictItme(key, res.data[key]);
    }
  });
}

const list =
  "edu_person_school_type,res_unit_type,true_or_false,mspjzq,msyy_status,wjpsd_dwlx,wjpsd_jglx,wjpsd_qykgqk,wjpsd_sjly,wjpsd_whzt,wjpsd_yjyysr,wjpsd_ywyyzz,wjpsd_yyzt,wjpsd_zcdjlx,wjpsd_zxkjbzlb";


const t1 = async () => {
  instance.getDictListAsync("edu_person_school_type").then((res) => {
    console.log("edu_person_school_type:", res);
  });
  instance.getDictListAsync("edu_person_school_type", 3000).then((res) => {
    console.log("edu_person_school_type:", res);
  });
  instance.getDictListAsync("edu_person_school_type").then((res) => {
    console.log("edu_person_school_type:", res);
  });
};

